<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<%@ page import="studio7.negocio.AdministradorNegocio"%>
	<%@ page import="studio7.modelo.Sala"%>
	<%@ page import="studio7.modelo.Servicio"%>
	<%@ page import="studio7.modelo.Instrumento"%>
	<%@ page import="studio7.modelo.SalaInstrumento"%>
	<%@page import="java.util.*"%>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
		<title>Armado de Sala</title>
	</head>
	<%
	String contextpath = request.getContextPath();
	%>
	
	<body>
		<form name="inicio" action="armadoSala2" method="post" style="height: 465px; width: 799px">
			
			
			
			
			
			
			<br><br>
			
			<%
			Object objMsg = request.getAttribute("msg");
			if(objMsg != null){
				String msg = objMsg.toString();
			%>
				<table>
					<tr>
						<td>
							<%=msg%>
						</td>
					</tr>
				</table>
			<%
			}
			%>
			<table style="width: 578px; ">
				<tr>
					<td style="width: 201px; ">
						<b>Instrumento</b>:<br/>
						<select size="1" name="idInstrumento" style="width: 140px; ">
							<%
							Object obj = session.getAttribute("arrayInstrumento");
							if(obj != null){
								Collection<Instrumento> col = ( Collection<Instrumento> ) obj;
								Iterator<Instrumento> i3 = col.iterator();
								while(i3.hasNext()){
									Instrumento instrumento = i3.next();
							%>
								<option value="<%=instrumento.getCodigoInstrumento()%>" selected><%=instrumento.getNombreInstrumento()%></option>
								<%
								}
							}	
							%>
						</select>
					</td>
					<td>
						<b>Cantidad</b>:
						<input type="text" name="cant" />
					</td>
				</tr>
				<tr>
					<td>
					</td>
					<td align="right">
						<input type="submit" value="Agregar">
					</td>
				</tr>
				<tr>
					<td colspan="2">
						<b>Listado de Instrumentos
						</b><table border="1" cellpadding="0" cellspacing="0">
							<tr>
								<td>
									<strong>Nombre Instrumento</strong>
								</td>
								<td>
									<strong>Cantidad</strong>
								</td>
							</tr>
							<%
							ArrayList<SalaInstrumento> array;
							obj = session.getAttribute("array");
							if(obj != null){
								System.out.println("pagina obj != null");
								array = ( ArrayList<SalaInstrumento> ) obj;
								System.out.println("array.size --> " + array.size());
								for(int j = 0; j < array.size(); j++){
									System.out.println("j --> " + j);
									SalaInstrumento bean = ( SalaInstrumento ) array.get(j);
									System.out.println("bean.getIdInstrumento() --> " + bean.getInstrumento_idInstrumento().getNombreInstrumento());
									System.out.println("bean.getCant() --> " + bean.getCantidad());
							%>
								<tr>
									<td style="width: 224px; ">
										<%=bean.getInstrumento_idInstrumento().getNombreInstrumento()%>
									</td>
									<td style="width: 357px; ">
										<%=bean.getCantidad()%>
									</td>
								</tr>
							<%
								}
							}else{
								System.out.println("obj == null");
							%>
								<tr>
									<td colspan="2">
										<i>No se encontraron resultados</i>
									</td>
								</tr>
							<%
							}
							%>
						</table>
					</td>
				</tr>
			</table>
		</form>
		<form name="inicio2" action="armadoSala3" method="post" style="height: 465px; width: 799px">
			<table>
				<tr>
					<td>
					</td>
					<td align="right" style="height: 32px; ">
						<input type="submit" value="Registrar">
					</td>
				</tr>
			</table>
		</form>
	</body>
</html>